package com.mashibing.juc.c_000;

/**
 * 创建线程的两种方式，第三种方式是通过线程池的方式启动
 * @author: Yuanzt
 * @Date: 2021/3/24
 */
public class T02_HowToCreateThread {

    static class MyThread extends Thread{
        @Override
        public void run(){System.out.println("Hello MyThread...");}
    }

    static class MyRun implements Runnable{
        @Override
        public void run() {System.out.println("Hello MyRun...");}
    }

    public static void main(String[] args) {
        //继承Thread类启动线程
        new MyThread().start();
        //实现Runnable接口启动线程
        new Thread(new MyRun()).start();
        //通过Lambda表达式启动线程
        new Thread(()->{
            System.out.println("Hello Lambda Thread...");
        }).start();
    }
}
